'use strict'

import Vue from 'vue'
import router from './router/router'
import footerComponent from './components/footer/footer'
import headerComponent from './components/header/header'
import leftComponent from './components/leftMenu/leftMenu'
import Axios from './api/api'
import Validator from 'vuelidate'
import 'babel-polyfill'
Vue.use(Validator)

Vue.prototype.$http = Axios
/*require('mock/data.js')*/
require('./css/base.less')
Vue.component('footer-nav', footerComponent)
Vue.component('header-nav', headerComponent)
Vue.component('left-nav', leftComponent)
Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.dataset.title
  }
});
Vue.filter('time', function (value) {//value为13位的时间戳
  function add0(m) {
    return m < 10 ? '0' + m : m
  }
  var time = new Date(parseInt(value));
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();

  return y + '年' + add0(m) + '月' + add0(d)+'日';
});
Vue.filter('timest', function (value) {//value为13位的时间戳
  function add0(m) {
    return m < 10 ? '0' + m : m
  }
  var time = new Date(parseInt(value));
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var h = time.getHours();
  var M = time.getMinutes();
  var s = time.getSeconds();

  return y + '年' + add0(m) + '月' + add0(d)+'日 '+h+':'+M+':'+s;
});
new Vue({
  router
}).$mount('#app')
